package com.fy.fyzf.presenter;

import com.fy.fyzf.api.SubscriberCallBack;
import com.fy.fyzf.base.BasePresenter;
import com.fy.fyzf.bean.CommonSearchBean;
import com.fy.fyzf.bean.ExChangeRecordBean;
import com.fy.fyzf.bean.ExchangeBean;
import com.fy.fyzf.bean.ExchangeBean1;
import com.fy.fyzf.bean.ExchangeDetailBean;
import com.fy.fyzf.bean.IntegralRecordBean;
import com.fy.fyzf.bean.IntegralStoreBean;
import com.fy.fyzf.bean.BaseData;
import com.fy.fyzf.bean.RulesBean;
import com.fy.fyzf.view.IntergralCallBack;

import java.util.List;

public class IntergralPresenter extends BasePresenter<IntergralCallBack> {

    public IntergralPresenter(IntergralCallBack view) {
        super(view);
    }

    public void getIntegralList(int pageNum,int pageSize,int type) {
    addSubscription(mApiService.listIntegralMall(pageNum, pageSize, type), new SubscriberCallBack<BaseData<IntegralStoreBean>>(mView,false) {
        @Override
        protected void onSuccess(BaseData<IntegralStoreBean> response) {
            mView.getIntegralListSuccess(response.data);
        }

        @Override
        protected void onError() {

        }
    });

    }

    public void exChange(ExchangeBean exchangeBean){
        addSubscription(mApiService.exchangeMall(exchangeBean), new SubscriberCallBack<BaseData<ExchangeBean>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<ExchangeBean> response) {
                mView.exchangeSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getExchangeDetail(ExchangeBean exchangeBean){
        addSubscription(mApiService.getExchangeDetail(exchangeBean), new SubscriberCallBack<BaseData<ExchangeDetailBean>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<ExchangeDetailBean> response) {
                mView.getExchangeDetailSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getExchangeRecord(CommonSearchBean searchBean){
        addSubscription(mApiService.getExchangeRecord(searchBean), new SubscriberCallBack<BaseData<ExChangeRecordBean>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<ExChangeRecordBean> response) {
                mView.getExchangeRecordSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getIntegralRecordList(CommonSearchBean searchBean) {
        addSubscription(mApiService.getIntegralRecord(searchBean), new SubscriberCallBack<BaseData<IntegralRecordBean>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<IntegralRecordBean> response) {
                    mView.getIntegralRecordListSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }

    public void getRules(){
        addSubscription(mApiService.getRules(), new SubscriberCallBack<BaseData<List<RulesBean>>>(mView,true) {
            @Override
            protected void onSuccess(BaseData<List<RulesBean>> response) {
                mView.getRulesSuccess(response.data);
            }

            @Override
            protected void onError() {

            }
        });
    }
}
